﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;

namespace tcpClient
{
    class Client
    {
        static void Main(string[] args)
        {
            TcpClient tcpClt = new TcpClient("127.0.0.1", 500);
            NetworkStream nst = tcpClt.GetStream();
            Byte[] sendMsg = Encoding.UTF8.GetBytes("Client Request Connetion!");
            nst.Write(sendMsg, 0, sendMsg.Length);
            nst.Flush();

            //接收信息
            Byte[] receiveMsg = new byte[1024];
            int count = nst.Read(receiveMsg, 0, receiveMsg.Length);
            Console.WriteLine("客户端接收到的:"+Encoding.UTF8.GetString(receiveMsg));
            Console.ReadKey();
        }
    }
}
